package cn.itsource.mapper;

import cn.itsource.domain.user.User;
import com.baomidou.mybatisplus.mapper.BaseMapper;

import java.util.Objects;

public interface UserMapper extends BaseMapper<User> {


    default boolean findPhoneExist (String phone){
        if(Objects.nonNull (this.findUserByPhone (phone))){
            return Boolean.TRUE;
        }else {
            return Boolean.FALSE;
        }
    };

    default User findUserByPhone (String phone){
        User user = new User();
        user.setPhone (phone);
        user = this.selectOne (user);

        if(Objects.isNull (user)){
            return null;
        }else{
            return user;
        }
    };
}
